package com.jiayang.hhotel.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.jiayang.hhotel.R;
import com.jiayang.hhotel.presenter.ContractTimeAddedPresenter;
import com.jiayang.hhotel.util.StringUtil;

import cn.droidlover.xdroidmvp.mvp.XActivity;

/**
 * Created by Administrator on 2017/5/27 0027.
 * 合同时间新增页面
 */

public class ContractTimeAddedActivity extends XActivity<ContractTimeAddedPresenter> implements View.OnClickListener {

    private TextView btStartDate,btEndDate,btLevel;//起始日期/终止日期/级别
    private Button btSave;//保存
    private String startDate,endDate,levelStr;//开始日期/结束日期/级别

    @Override
    public void initData(Bundle savedInstanceState) {

        initTitle(this,true,getString(R.string.newly_added),R.color.orange_color,null,null);
        btStartDate= (TextView) findViewById(R.id.bt_start_date);
        btEndDate= (TextView) findViewById(R.id.bt_end_date);
        btLevel= (TextView) findViewById(R.id.bt_jibie);
        btSave= (Button) findViewById(R.id.bt_save);

        btStartDate.setOnClickListener(this);
        btEndDate.setOnClickListener(this);
        btLevel.setOnClickListener(this);
        btSave.setOnClickListener(this);
    }

    @Override
    public int getLayoutId() {
        return R.layout.layout_contract_time_added;
    }

    @Override
    public ContractTimeAddedPresenter newP() {
        return new ContractTimeAddedPresenter();
    }

    /**
     * 设置开始日期
     * @param date 日期
     */
    public void setStartDate(String date){
        if (!StringUtil.isEmpty(date)) {
            startDate=date;
            btStartDate.setText(date);
        }
    }

    /**
     * 设置终止日期
     * @param date 日期
     */
    public void setEndDate(String date){
        if(!StringUtil.isEmpty(date)){
            endDate=date;
            btEndDate.setText(date);
        }
    }

    public void setLevel(String level){
        levelStr = level;
        btLevel.setText(level);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.bt_start_date://选择开始日期
                getP().initDatePicker(this,false,startDate,endDate);
                break;
            case R.id.bt_end_date://选择终止日期
                getP().initDatePicker(this,true,startDate,endDate);
                break;
            case R.id.bt_jibie://选择级别
                getP().LevelDialog(this);
                break;
            case R.id.bt_save://保存
                break;
        }
    }
}
